package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoInsertFill;
import com.sky.annotation.AutoUpdateFill;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     *
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 根据用户查询数量
     *
     * @param employee 员工
     * @return {@link Integer}
     */
    Integer selectCountByUsername(Employee employee);

    /**
     * 插入员工
     *
     * @param employee 员工
     */
    @AutoInsertFill
    void insert(Employee employee);

    /**
     * 分页查询
     *
     * @param employee 员工
     * @return {@link Page}<{@link Employee}>
     */
    Page<Employee> selectPage(Employee employee);

    /**
     * 更新通过id
     *
     * @param employee 员工
     */
    @AutoUpdateFill
    void updateById(Employee employee);

    /**
     * 选择通过id
     *
     * @param id id
     * @return {@link Employee}
     */
    Employee selectById(Long id);

    /**
     * 选择排除数由用户名
     *
     * @param username 用户名
     * @param id       id
     * @return {@link Integer}
     */
    Integer selectCountByUsernameToRuleOut(String username, Long id);
}
